<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>User</title>
<link href="<c:url value="/resources/css/laps.css"></c:url>"
	rel="stylesheet" />
<!-- Bootstrap core CSS -->
<link href="<c:url value="/resources/css/bootstrap.min.css"></c:url>"
	rel="stylesheet">
<link href="<c:url value="/resources/css/bootstrap-reset.css"></c:url>"
	rel="stylesheet">
<!-- external css-->
<link
	href="<c:url value="/resources/assets/font-awesome/css/font-awesome.css"></c:url>"
	rel="stylesheet" />

<link rel="stylesheet" type="text/css"
	href="<c:url value="/resources/assets/bootstrap-datepicker/css/datepicker.css"></c:url>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/resources/assets/bootstrap-colorpicker/css/colorpicker.css"></c:url>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/resources/assets/bootstrap-daterangepicker/daterangepicker.css"></c:url>" />

<!-- Custom styles for this template -->
<link href="<c:url value="/resources/css/style.css"></c:url>"
	rel="stylesheet">
<link href="<c:url value="/resources/css/style-responsive.css"></c:url>"
	rel="stylesheet" />
</head>
<body>
	<jsp:useBean id="roles" class="java.util.ArrayList" scope="page">
		<%
			roles.add("Admin");
				roles.add("Supervisor");
				roles.add("Staff");
		%>
	</jsp:useBean>
	<jsp:useBean id="default_pages" class="java.util.ArrayList" scope="page">
	<%
	default_pages.add("/calendar");
	default_pages.add("/leaves");
	default_pages.add("/leaves/applied");
	default_pages.add("/employees");
	default_pages.add("/holidays");
	%>
	</jsp:useBean>
	<div class="row">
		<div class="col-lg-12">
			<section class="panel"> <header class="panel-heading">
			User Form </header>
			<div class="panel-body">
				<form class="form-horizontal" role="form" method="post" onsubmit="return isValid();">
					<input type="hidden" value="${isSelf }" name="profile" />
					<div class="form-group">
						<label class="col-lg-2 col-sm-2">Employee ID</label>
						<div class="col-lg-3">
							<c:choose>
								<c:when test="${employee.employeeID == ''}">
									<input type="text" class="form-control" name="employeeID"
										placeholder="User ID" required value="${employee.employeeID}" />
								</c:when>
								<c:otherwise>
									<input type="text" class="form-control"
										placeholder="User ID" required value="${employee.employeeID}"
										disabled />
									<input type="hidden" value="${employee.employeeID}" name="employeeID" />
								</c:otherwise>
							</c:choose>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2">Name</label>
						<div class="col-lg-3">
							<input type="text" class="form-control" name="name"
								placeholder="Name" required value="${employee.name }" />
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2"> Password</label>
						<div class="col-lg-3">
							<input id="txtPwd" type="password" class="form-control" name="password"
								placeholder="Password" value="${e_user.password }" required>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2">Confirm password</label>
						<div class="col-lg-3">
							<input id="txtPwdConfirm" type="password" class="form-control"
								name="txtConfirmPassword" placeholder="Confirm password"
								value="${e_user.password }" required>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2">Email</label>
						<div class="col-lg-3">
							<input type="email" class="form-control" name="email"
								placeholder="Email" value="${employee.email }" required>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2">Supervisor ID</label>
						<div class="col-lg-3">
							<c:choose>
								<c:when test="${empty isSelf }">
									<input type="text" class="form-control" name="supervisorID"
								placeholder="Supervisor ID" value="${employee.supervisorID }" />
								</c:when>
								<c:otherwise>
									<input type="text" class="form-control"
								placeholder="Supervisor ID" value="${employee.supervisorID }" disabled />
									<input type="hidden" name="supervisorID" value="${employee.supervisorID }" />
								</c:otherwise>
							</c:choose>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2">Phone</label>
						<div class="col-lg-3">
							<input type="text" class="form-control" name="phone"
								placeholder="Phone" value="${employee.phone }" required>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2">User Type</label>
						<div class="col-lg-3">
							<c:choose>
								<c:when test="${empty isSelf }">
									<select class="form-control input-sm m-bot15" name="type">
										<c:if test="${e_user.type != '' }">
											<option value="${e_user.type }">${e_user.type }</option>
										</c:if>
										<c:forEach items="${roles }" var="role">
											<c:if test="${role != e_user.type }">
												<option value="${role }">${role }</option>
											</c:if>
										</c:forEach>
									</select>
								</c:when>
								<c:otherwise>
									<input type="text" name="type" class="form-control" value="${e_user.type }"
										disabled />
									<input type="hidden" name="type" value="${e_user.type }" />
								</c:otherwise>
							</c:choose>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2">Entitlement</label>
						<div class="col-lg-3">
							<c:choose>
								<c:when test="${empty isSelf }">
									<select name="leaveEntitlementID" class="form-control">
								<c:forEach items="${entitlements }" var="en">
									<c:choose>
										<c:when test="${en.entitlementID != employee.leaveEntitlementID }">
											<option value="${en.entitlementID}">${en.designation }</option>
										</c:when>
										<c:otherwise>
											<option value="${en.entitlementID}" selected="selected">${en.designation }</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
							</select>
								</c:when>
								<c:otherwise>
									<c:forEach items="${entitlements }" var="en">
										<c:if test="${en.entitlementID == employee.leaveEntitlementID }">
											<input type="text" class="form-control" value="${en.designation }" disabled />
									<input type="hidden" name="leaveEntitlementID" value="${en.entitlementID}" />
										</c:if>
									</c:forEach>
								</c:otherwise>
							</c:choose>
						</div>
					</div>
					<div class="form-group">
						<label class="col-lg-2 col-sm-2">Default Page</label>
						<div class="col-lg-3">
							<select name="defaultPage" class="form-control">
								<c:if test="${e_user.defaultPage != '' }">
									<option value="${e_user.defaultPage}">${e_user.defaultPage }</option>
								</c:if>
								<c:forEach items="${default_pages }" var="page">
									<c:if test="${page != e_user.defaultPage }">
										<option value="${page}">${page }</option>
									</c:if>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="form-group">
						<div class="col-lg-offset-2 col-lg-10">
							<c:choose>
								<c:when test="${employee.employeeID == '' }">
									<button type="reset" class="btn btn-primary" name="new">New</button>
									<button type="submit" class="btn btn-primary" name="save">Save</button>
								</c:when>
								<c:otherwise>
									<button type="reset" class="btn btn-primary" name="reset">Reset</button>
									<button type="submit" class="btn btn-primary" name="edit">Save</button>
									<c:if test="${empty isSelf }">
										<button type="submit" class="btn btn-primary" name="delete">Delete</button>
									</c:if>
								</c:otherwise>
							</c:choose>
						</div>
					</div>
				</form>
			</div>
			</section>
		</div>
	</div>
	<!-- js placed at the end of the document so the pages load faster -->
	<script src="<c:url value="/resources/js/jquery.js"></c:url>"></script>
	<script src="<c:url value="/resources/js/bootstrap.min.js"></c:url>"></script>
	<script
		src="<c:url value="/resources/js/jquery.scrollTo.min.js"></c:url>"></script>
	<script
		src="<c:url value="/resources/js/jquery.nicescroll.js"></c:url>"
		type="text/javascript"></script>

	<script
		src="<c:url value="/resources/js/jquery-ui-1.9.2.custom.min.js"></c:url>"></script>
	<script class="include" type="text/javascript"
		src="<c:url value="/resources/js/jquery.dcjqaccordion.2.7.js"></c:url>"></script>
	<!--common script for all pages-->
	<script src="<c:url value="/resources/js/common-scripts.js"></c:url>"></script>

	<script type="text/javascript"
		src="<c:url value="/resources/assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></c:url>"></script>
	<script type="text/javascript"
		src="<c:url value="/resources/assets/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></c:url>"></script>
	<script type="text/javascript"
		src="<c:url value="/resources/assets/bootstrap-daterangepicker/moment.min.js"></c:url>"></script>
	<script type="text/javascript"
		src="<c:url value="/resources/assets/bootstrap-daterangepicker/daterangepicker.js"></c:url>"></script>
	<script type="text/javascript"
		src="<c:url value="/resources/assets/bootstrap-timepicker/js/bootstrap-timepicker.js"></c:url>"></script>
	<script>
		function isValid()
		{
			var pwd = document.getElementById("txtPwd").value;
			var cpwd = document.getElementById("txtPwdConfirm").value;
			if(pwd!=cpwd)
			{
				alert("Password does not match!");
				return false;
			}
			return true;
		}
	</script>
</body>
</html>